/****************************************************************************
 *
 * Copyright (C) 2003-2008 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.gui.client;

import nfse.gui.record.FlexRecord;

//import com.google.gwt.user.client.ui.FormPanel;
//import com.google.gwt.user.client.ui.Label;
import com.gwtext.client.core.RegionPosition;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.form.*;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;

public class EventViewerDialog extends Window {

    public EventViewerDialog(FlexRecord flex) {

        final EventViewerDialog thisDialog = this;

        this.setShadow(true);
        this.setFrame(true);

        this.setIconCls("pac-icon");

        // center panel
        Panel optionsPanel = new Panel();
        // optionsPanel.setAutoHeight(true);
        // optionsPanel.setAutoWidth(true);
        // optionsPanel.set

        // east panel
        // Panel schemaPanel = new Panel();
        // schemaPanel.setTitle("Schema");
        // schemaPanel.setAutoHeight(true);
        // schemaPanel.setAutoWidth(true);
        // schemaPanel.setWidth("100%");
        // schemaPanel.setCollapsible(true);
        // String schemaHTML = "";

        // schemaPanel.setHtml(schemaHTML);

        BorderLayoutData centerData = new BorderLayoutData(RegionPosition.CENTER);
        centerData.setMargins(3, 0, 3, 3);

        // BorderLayoutData eastData = new
        // BorderLayoutData(RegionPosition.EAST);
        // eastData.setSplit(true);
        // eastData.setMargins(3, 3, 0, 3);
        // eastData.setCMargins(3, 3, 3, 3);

        this.setTitle("Event Viewer");
        

        setLayout(new BorderLayout());
        add(optionsPanel, centerData);
        // add(schemaPanel, eastData);
        setCloseAction(Window.HIDE);

        final EventViewerDialog del = this;

        // FlexTable table = new FlexTable();
        FormPanel form = new FormPanel();
        int idx = -1;

        for (int i = 0; i < flex.values.length; i++) {
            // Label label = new Label(flex.colNames[i]);
            TextField field = new TextField(flex.colNames[i], flex.values[i], 230);
            field.setValue(flex.values[i]);
            field.setReadOnly(true);
            form.add(field);
            // table.setWidget(++idx, 0, label);
            // table.setWidget(idx, 1, field);
        }

        // table.setWidget(++idx, 0, buttons);
        // this.setWidget(table);

        // optionsPanel.add(table);
        setClosable(true);
        setWidth(350);
        setResizable(true);
        //setHeight(300);
        
        // setPlain(true);
        this.setModal(true);
        optionsPanel.add(form);
        
        

    }

}
